#ifndef _DSWAX_MSG_CLIENT_H
#define _DSWAX_MSG_CLIENT_H
#include <libbase/dswtcpclient_base.h>

typedef struct{
	gm_dim_t nDIM;
	int nFps;
} ST_AX_DIM_FPS_T, *LPST_AX_DIM_FPS_T;

typedef void (*CB_AX_MSG_CLIENT)(EN_MSG_TYPE nType, char* pKey, void* pParam, void* pCaller);

class CDswax_msg_client : public CDswtcpclient_base
{
public:
	CDswax_msg_client(LPST_ENV_T pEnv, char* pHost, int nPort, CB_AX_MSG_CLIENT pCBFunc, void* pCaller, char* pDevID);
	virtual ~CDswax_msg_client();
public:
	void PostDestroyClient();
	void DestroyClient();
	static bool cbOnPUARegistV2(char* pCId, void* pMsgReq, const char* pMsgIDResp, void* pCaller){return ((CDswax_msg_client*)pCaller)->OnPUARegistV2(pCId, pMsgReq, pMsgIDResp);};
	static bool cbOnGetParamModifyV2(char* pCId, void* pMsgReq, const char* pMsgIDResp, void* pCaller){return ((CDswax_msg_client*)pCaller)->OnGetParamModifyV2(pCId, pMsgReq, pMsgIDResp);};
	static bool cbOnGetParamV2(char* pCId, void* pMsgReq, const char* pMsgIDResp, void* pCaller){return ((CDswax_msg_client*)pCaller)->OnGetParamV2(pCId, pMsgReq, pMsgIDResp);};
	static bool cbOnGetPTZSetV2(char* pCId, void* pMsgReq, const char* pMsgIDResp, void* pCaller){return ((CDswax_msg_client*)pCaller)->OnGetPTZSetV2(pCId, pMsgReq, pMsgIDResp);};

private:
	bool OnPUARegistV2(char* pCId, void* pMsgReq, const char* pMsgIDResp);
	bool OnGetParamModifyV2(char* pCId, void* pMsgReq, const char* pMsgIDResp);
	bool OnGetParamV2(char* pCId, void* pMsgReq, const char* pMsgIDResp);
	bool OnGetPTZSetV2(char* pCId, void* pMsgReq, const char* pMsgIDResp);

	void SendMsg(char * pMsg);

	static void cbMonitorTask(int fd, short events, void* ctx){((CDswax_msg_client*)ctx)->MonitorTask(fd, events);};
	void MonitorTask(int fd, short events);
	static void cbMonitorCmdTask(int fd, short events, void* ctx){((CDswax_msg_client*)ctx)->MonitorCmdTask(fd, events);};
	void MonitorCmdTask(int fd, short events);
protected:
	virtual void OnError(struct bufferevent *bev, short events);
	virtual void OnConnect(struct bufferevent *bev, short events);
	virtual int MakePayloadLength(char* pData, int nLen);
	virtual bool ProcessMessage(char* pMsg, int nLen, struct evbuffer *outbuf);
private:
	bool m_bNeedReconnect, m_bValid;
	CB_AX_MSG_CLIENT m_pCBFunc;
	void* m_pCaller;
	char m_sDevID[32], m_sCurParamTM[32];
	ST_DEVICE_BASE_T m_nBaseParam;
	ST_TIMER_PARAM_T m_nTask_Monitor, m_nTask_CmdMonitor;
};

#endif

